export default {
	data() {
		return {
			//数据
      validate: {}, //验证对象
      achievement: {} //成果信息
		}
	},
	created() { //调用方法
	},
	mounted() {
    let that = this;
    UE.delEditor('editor');
    var ue = UE.getEditor('editor');

    //加载表单验证
    that.validate = $("#achievementForm").validate({
      ignore: [],
      rules: {
        name: { // 新闻发布名称
          required: true,
          maxlength: 100
        },
        content: { // 新闻发布内容
          required: true,
          maxlength: 200
        }
      },
      messages: {
        name: { // 新闻发布名称
          required: "请输入新闻发布标题",
          maxlength: "请输入长度小于100"
        },
        content: { // 新闻发布内容
          required: "请输入主要任务",
          maxlength: "请输入长度小于200"
        }
      },
      errorElement: "em",
      errorPlacement: function (error, element) {
        error.appendTo(element.parents(".error-box").children(".error-msg"));
      }
    });
	},
	methods: { //写函数方法
    //保存并发布
    saveAndRelease: function () {
      let that = this;
      let flg = that.validate.form();
      if (flg) {
        let dataObj = that.combinationFormObject(that.validate.currentForm);
        that.$post(
          that.urls.addPortalIntroduce,
          dataObj
        )
          .then(function(res) {
            let msg = "";
            if(res.success) {
              msg = "保存并发布成果成功！";
            } else {
              msg = "保存并发布成果失败！";
            }
            layer.msg(msg, {
              time: 3000, //3s后自动关闭
            });
          })
      }
    }
	}
}
